package fr.SDroid.Graph;

import java.io.Serializable;
import java.util.Vector;



public class Graph implements Serializable{
	
	/**
	 * To make java Happy
	 */
	private static final long serialVersionUID = 1L;
	private String _ville = new String();
	
	private Vector<Ligne> _listLigne = new Vector<Ligne>();
	private Double _version ;
	private Station _stationDepart;
	private Station _stationArrive;
	
	Station sta1 = null;
	Station sta2 = null;
	
	public Graph() {
		_listLigne = new Vector<Ligne>();
	}
	
	public void setVersion(Double version) {
		_version = version;
	}
	
	public Double getVersion() {
		return _version;
	}

	public void setVille(String ville) {
		_ville = ville;
	}
	
	public String getVille() {
		return _ville;
	}

	public void createCoresp(Station station1, Station station2) {
		station1.addCoresp(station2);
		station2.addCoresp(station1);
	}
	
	public void createCoresp(Integer station1, Integer station2) {
		
		
		for(int li = 0; li < _listLigne.size(); li++) {
			Ligne ligne = _listLigne.get(li);
			for(int sta = 0; sta < ligne.getListStation().size(); sta++) {
				Station temp = ligne.getListStation().get(sta);
				if(temp.getId().equals(station1))
					sta1 = temp;
				if(temp.getId().equals(station2))
					sta2 = temp;
			}
		}
		
		if(sta1 != null && sta2 != null)
			createCoresp(sta1, sta2);
		else
			System.out.println("erreur creation correspondance");
	}
	
	public void addLigne(Ligne ligne) {
		_listLigne.add(ligne);
	}
	
	public Vector<Ligne> getLignes(){
		return _listLigne;
	}
	
	public void setStationDepart(Station station) {
		_stationDepart = station;
	}
	public void setStationArrive(Station station) {
		_stationArrive = station;
	}
	
	public Station getDepart() {
		return _stationDepart;
	}
	
	public Station getArrive() {
		return _stationArrive;
	}

	
	
}
